import {initRequest,myRequest} from "../../api/myRequest";
import $actions from '../constant/actions'
const _DocsManage = 'DocsManage';
const _DownloadFile = 'DownloadFile';
const _DownloadFileById = 'DownloadFileById';
const _UploadFile = 'UploadFile';
const _UploadFiles = 'UploadFiles';
const _DeleteFile = 'DeleteFile';
const _DeleteFileById = 'DeleteFileById';
const BaseDocs ={
	/**
	 * 添加信息
	 * @param record
	 * @returns {Promise<*>}
	 */
	add(record) {
		return myRequest(_DocsManage,[{action: $actions.ADD, data: [record]}]);
	},

	/**
	 * 删除信息
	 * @param id
	 * @returns {Promise<*>}
	 */
	delete(filter) {
		return myRequest(_DocsManage,[{action: $actions.INSTANCE_DELETE, ...filter}]);
	},

	/**
	 * 按Id删除信息
	 * @param ids
	 * @returns {Promise<*>}
	 */
	deleteById(id) {
		return myRequest(_DocsManage,[{action: $actions.INSTANCE_DELETE_BY_ID, id: id}]);
	},

	/**
	 * 批量删除信息
	 * @param ids
	 * @returns {Promise<*>}
	 */
	batchDelete(filter) {
		return myRequest(_DocsManage,[{action: $actions.BATCH_DELETE, ...filter}]);
	},


	/**
	 * 批量删除信息
	 * @param ids
	 * @returns {Promise<*>}
	 */
	deleteByIds(ids) {
		return myRequest(_DocsManage,[{action: $actions.BATCH_DELETE, ids: ids}]);
	},

	/**
	 * 更新信息
	 * @param record
	 * @returns {Promise<*>}
	 */
	update(record) {
		return myRequest(_DocsManage,[{action: $actions.UPDATE, data: [record]}]);
	},

	/**
	 * 查询列表
	 * @param recipient
	 * @returns {Promise<*>}
	 */
	query(filter) {
		let recipient = [{action: $actions.QUERY,...filter}]
		return myRequest(_DocsManage,recipient);
	},

	/**
	 * 简单查询不包括属性或大字段信息
	 * @param filter
	 * @returns {Promise<*>}
	 */
	queryInfo(filter) {
		let recipient = [{action: $actions.QUERY_INFO,...filter}]
		return myRequest(_DocsManage,recipient);
	},

	/**
	 * 分页查询列表
	 * @param recipient
	 * @returns {Promise<*>}
	 */
	queryByPage(pageNumber, pageSize, filter, orderBy={}) {
		let recipient = [{action: $actions.QUERY_BY_PAGE, pageNumber: pageNumber, pageSize: pageSize, ...filter,orderBy}]
		return myRequest(_DocsManage,recipient);
	},
	/**
	 * 分页查询列表
	 * @param recipient
	 * @returns {Promise<*>}
	 */
	queryInfoByPage(pageNumber, pageSize, filter) {
		let recipient = [{action: $actions.QUERY_BY_PAGE, pageNumber: pageNumber, pageSize: pageSize, ...filter}]
		return myRequest(_DocsManage,recipient);
	},
	/**
	 * 根据ids获取数据列表
	 * @param ids
	 * @returns {AxiosPromise}
	 */
	downloadFile(param){
		return myRequest(_DownloadFile,param)
	},
	/**
	 * 根据id获取数据列表
	 * @param id
	 * @returns {AxiosPromise}
	 */
	downloadFileById(id){
		return myRequest(_DownloadFileById,{id:id})
	},
	/**
	 * 根据ids获取数据列表
	 * @param param
	 * @returns {AxiosPromise}
	 */
	 uploadFile(param){
		return myRequest(_UploadFile,param)
	},
	/**
	 * 根据ids获取数据列表
	 * @param param
	 * @returns {AxiosPromise}
	 */
	uploadFiles(param){
		return myRequest(_UploadFiles,param)
	},
	/**
	 * 根据ids获取数据列表
	 * @param param
	 * @returns {AxiosPromise}
	 */
	deleteFile(param){
		return myRequest(_DeleteFile,param)
	},

	/**
	 * 根据id获取数据列表
	 * @param id
	 * @returns {AxiosPromise}
	 */
	deleteFileById(id){
		return myRequest(_DeleteFileById,{id:id})
	},
	
}

export default BaseDocs;
